/*
*************************************
* PocketGTT
*************************************
This file is part of PocketGTT.

PocketGTT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PocketGTT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PocketGTT.  If not, see <http://www.gnu.org/licenses/>.
*/

import QtQuick 1.0


Rectangle {
    height: textGroup.height  + 20   //85
    width: parent.width

    color: "transparent"
//    color: myWin.theme.preferred_list_background // "#4d4d4d60"

    property int count: ListView.view.count

    clip: true

    Item {
        id: textGroup
        height: sTitle.height + sStreet.height
        width: parent.width - 50
        anchors.left: parent.left
        anchors.leftMargin: 8
        //        anchors.right: btnImgInfoBack.left
        //        anchors.rightMargin: 8
        //        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter

        Text {
            id: sTitle
            text: stopNumber + " - " + stopName

            anchors.top: parent.top
            //            anchors.horizontalCenter: parent.horizontalCenter
            anchors.left: parent.left
            //            anchors.right: parent.right
            width: parent.width
            horizontalAlignment: Text.AlignHCenter

            color: "white"

            font.pixelSize: myWin.theme.textSizeM  //26
            wrapMode: Text.Wrap

        }

        Text {
            id: sStreet
            text: stopStreet

            anchors.top: sTitle.bottom
            anchors.topMargin: 2
            anchors.left: parent.left
            //            anchors.right: parent.right
            width: parent.width
            horizontalAlignment: Text.AlignLeft

            color: "white"

            font.pixelSize: myWin.theme.textSizeS //14
            wrapMode: Text.Wrap
        }
    }


    Item {
        anchors.right: parent.right
        anchors.left: textGroup.right
        anchors.verticalCenter: textGroup.verticalCenter
        height: textGroup.height

        ListArrow {
            pressed: listMA.pressed
            pressedColor:  myWin.theme.blue_background
        }

    }



    Separator {
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        height: (index===0) ? 0 : 1
        color: myWin.theme.blue_background //"#09a7cc"
    }
    // find a way to remove to bottom separator for the last item!!!
    Separator {
        anchors.bottom: parent.bottom
        anchors.horizontalCenter: parent.horizontalCenter
        height: (index === (parent.count-1)) ? 0 : 1
        color: myWin.theme.blue_background //"#09a7cc"

    }

    MouseArea {
        id: listMA
        anchors.fill: parent
        onClicked: GTT.searchByString(stopNumber);
        onPressAndHold: GTT.removePreferred(index);
    }

    // cannot animate the reordering of elements in the preferred list...
    // think about something else, code not working
    //    transitions: [
    //        Transition {
    //            NumberAnimation { properties: "x"; duration: myWin.theme.changetimeXS}
    //            //            ColorAnimation { duration: changetime }
    //            //            PropertyAnimation { properties: "text"; duration: 400}
    //        }
    //    ]


}

